<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>实物资产出库管理</title>
    <script charset="utf-8" src="../../../../../res/js/jquery-3.4.1.min.js"></script>
    <script charset="utf-8" src="../../../../../res/js/login_common.js"></script>
    <script charset="utf-8" src="../../../../../res/layui/layui.js"></script>
    <script charset="utf-8" src="../../../../../res/js/Tools.js"></script>
    <script charset="utf-8" src="../../../../../res/js/error.js"></script>
    <link href="../../../../../res/images/favicon.ico" rel="shortcut icon" type="image/x-icon">
    <link href="../../../../../res/layui/css/layui.css" media="all" rel="stylesheet">
</head>
<body style="padding: 10px">
<form action="" class="layui-form layui-form-pane">
    <input id="pkDeliverFromGodownId" name="pkDeliverFromGodownId" type="hidden"/>
    <div class="layui-form-item">
        <label class="layui-form-label">资产名</label>
        <div class="layui-input-block">
            <select id="assetName" name="assetName"></select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">使用人</label>
        <div class="layui-input-block">
            <select id="personnelId" name="personnelId">
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block" id="flows">
            <input class="layui-btn layui-btn-normal" id="demo3" type="button" value="退出">
        </div>
    </div>
</form>

<script>
    var form = null;
    let pkDeliverFromGodownId = getQueryString("pkDeliverFromGodownId");
    // 修改赋值
    layui.use(['form', 'layer'], function () {
        layer = layui.layer
            , form = layui.form;
        //自定义
        loadassetName();
        loadPerson();
        if (pkDeliverFromGodownId) {
            findById(pkDeliverFromGodownId);
        }
        form.render();


        $("#demo3").on("click", function () {
            //询问框
            layer.confirm('是否关闭该页面？', {
                btn: ['是的', '取消'] //按钮
            }, function () {
                formClose();
                parent.layui.table.reload('test');//刷新父页面
                //window.parent.location.reload();//刷新父页面
                const index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                parent.layer.close(index);
            });
        });

    });

    function findById(pkDeliverFromGodownId) {
        let url = getRootPath() + "/OaDeliverFromGodownAction/deliverFromGodownFindById/" + pkDeliverFromGodownId;
        let data = getAjaxById(url);
        console.log(data);
        $("#pkDeliverFromGodownId").val(data.data.pkDeliverFromGodownId);
        $("#pkDeliverFromGodownId").attr("disabled", "disabled");
        $("#assetName").val(data.data.assetName);
        $("#assetName").attr("disabled", "disabled");
        $("#personnelId").val(data.data.personnelId);
        $("#personnelId").attr("disabled", "disabled");
        form.render("select");
    }
    /**
     *领取人
     * */

    function loadPerson() {
        var url = getRootPath() + "OaPersonnelAction/personnelFindByAll";
        var data = getAjax(url, null);
        $.each(data.data, function (index, item) {
            $("#personnelId").append("<option value='" + item.pkPersonnelId + "'>" + item.personnelName + "</option>");
        });
    }

    /**
     * 领取的产品
     */
    function loadassetName() {
        var url = getRootPath() + "/OaAssetAction/selectAll";
        var data = getAjax(url, null);
        $.each(data.data, function (index, item) {
            $("#assetName").append("<option value='" + item.pkAssetId + "'>" + item.assetName + "(" + item.pkAssetId + ")" + "</option>");
        });
    }


</script>
</body>
</html>